package com.ljf.authority.infra.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ljf.authority.domain.repository.AuthorityRelPermissionGroupMenuRepository;
import com.ljf.authority.dto.query.AuthorityRelPermissionGroupMenuQuery;
import com.ljf.authority.infra.mapper.AuthorityRelPermissionGroupMenuMapper;
import com.ljf.authority.model.AuthorityRelPermissionGroupMenu;
import com.ljf.authority.vo.AuthorityRelPermissionGroupMenuVO;
import com.ljf.common.exception.ServiceException;
import com.ljf.common.infra.repository.impl.BasisRepositoryImpl;
import com.ljf.common.utils.CollectionUtil;
import com.ljf.common.utils.StringUtil;
import org.springframework.stereotype.Component;

/**
 * 权限组菜单关联  数据访问接口实现
 *
 * @author LJF
 * @since 2024-10-30
 */
@Component
public class AuthorityRelPermissionGroupMenuRepositoryImpl extends BasisRepositoryImpl<AuthorityRelPermissionGroupMenuMapper, AuthorityRelPermissionGroupMenu, AuthorityRelPermissionGroupMenuQuery, AuthorityRelPermissionGroupMenuVO> implements AuthorityRelPermissionGroupMenuRepository {

    @Override
    protected QueryWrapper<AuthorityRelPermissionGroupMenu> fillWrapper(AuthorityRelPermissionGroupMenuQuery query, boolean sort) throws ServiceException {
        QueryWrapper<AuthorityRelPermissionGroupMenu> wrapper = super.fillWrapper(query, sort);
        if (CollectionUtil.isNotEmpty(query.getMenuCodeList())) {
            wrapper.in(AuthorityRelPermissionGroupMenu.COL_MENU_CODE, query.getMenuCodeList());
        }
        if (CollectionUtil.isNotEmpty(query.getGroupCodeList())) {
            wrapper.in(AuthorityRelPermissionGroupMenu.COL_GROUP_CODE, query.getGroupCodeList());
        }
        if (StringUtil.isNotEmpty(query.getMenuCodeRightLike())) {
            wrapper.likeRight(AuthorityRelPermissionGroupMenu.COL_MENU_CODE, query.getMenuCodeRightLike());
        }
        return wrapper;
    }

}
